﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineHelpDesk.BLL_Service;

namespace OnlineHelpDesk.Admin
{
    public partial class AdminCreateAccount : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Service1 S = new Service1();
                ddlUserType.DataSource = S.getAllUserTypeName();
                ddlUserType.DataValueField = "TypeName";
                ddlUserType.DataBind();
                
            }
        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            Service1 S = new Service1();
            int typeID = S.getTypeIDbyName(ddlUserType.SelectedItem.Text.ToString());
            S.InsertUser(txtUserID.Text, txtUserName.Text, txtPassword.Text, txtUserFullName.Text,Convert.ToInt32(txtUserAge.Text),ddlGender.SelectedItem.Text.ToString(),txtUserEmail.Text,typeID,0);
            Response.Redirect("UserManagement.aspx");
        }
    }
}